package com.example.order.web;

import com.example.order.bean.User;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;

@RestController
public class order {
    @GetMapping("order")
    public String index(HttpServletRequest request){
        return "order: " + request.getServerPort();
    }


    //传入参数
    @RequestMapping("hello")
    public String hello(@RequestParam  String name){
        return "hello" + name;
    }

    @RequestMapping("add")
    public int add(@RequestParam int a, @RequestParam int b){
        return a + b;
    }

    @RequestMapping("reg")
    public User reg(@RequestBody User user){
        user.setAge(user.getAge() + 10);
        return user;
    }

    @RequestMapping("reg1")
    public User reg (@RequestBody User user, @RequestParam int age){
        user.setAge(user.getAge() + age);
        return user;
    }
}
